<%-- 
    Document   : tempContent
    Created on : 2011-4-13, 15:16:25
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.io.*,java.util.*,java.sql.*,java.net.*,java.text.*"%>
<%@include file="top.jsp" %>
<%@page import="com.news.util.Pager"%>
<%@page import="com.news.bean.NewsType"%>
<%@page import="com.news.bean.News"%>
<%@page import="com.news.dao.impl.*" %>
<%@page import="java.util.*" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="text/css">
            #ContentL h1{
                height:40px;
                line-height:40px;/*设置行距，目的是保证h1中的文字垂直居中*/
                font-size:16px;
                color:#054d73;
                border-bottom:1px #969696 dashed;/*设置h1的下边框为宽度1像素的虚线*/
                margin-bottom:10px;/*设置外边距，让h1和下面的内容区域p保持10像素的距离*/
            }
            #ContentL p{
                font-size:12px;
                line-height:20px;
                text-indent:2em;/*这句话的目的就是为了让文章第一行缩进两个汉字，记住这句话就OK了*/
            }
            #ContentL p img{
                float:left;
                margin-right:10px;
            }
        </style>
        <title>JSP Page</title>
    </head>
    <body>
        <%

            String id = request.getParameter("id");
            int newsId = Integer.parseInt(id.substring(0,id.indexOf(".")));
            News news = new NewsDaoImpl().get(newsId);
            URL server = null;
            try {
                String urlStr = "";
                urlStr = "http://" + request.getServerName() + ":" + request.getServerPort() + "/HBLPro/Figure";
                server = new URL(urlStr);
            } catch (Exception e) {
                System.out.println("Exception 1 = " + e);
            }
            ObjectInputStream reply = null;
            Object result = null;
            try {
                URLConnection con = server.openConnection();
                con.setDoInput(true);
                con.setDoOutput(true);
                con.setUseCaches(false);
                con.setRequestProperty("Content-Type", "application/octet-stream");
                con.setAllowUserInteraction(false);
                ObjectOutputStream command =
                        new ObjectOutputStream(
                        new BufferedOutputStream(con.getOutputStream()));
                command.writeObject("getRealPath");
                command.flush();
                command.close();
                ObjectInputStream in = new ObjectInputStream(con.getInputStream());
                result = in.readObject();
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("Exception 2 = " + e);
            }
            String path = "http://" + request.getServerName() + ":" + request.getServerPort() + "/HBLPro/Figure";

            String imagePath = "";
            imagePath = path + "/" + id;
            System.out.println(imagePath);
            java.awt.Image img = null;
            try {
                img = javax.imageio.ImageIO.read(new File(imagePath));
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        %>
        <p></p>
        <br>
        <br>
        <div id="ContentL">
            <h1><%=news.getTitle()%></h1>
            <p><img name="fig" id="fig" src="<%=path%>/<%=id%>"  width="400px" height="350px"><%=news.getMessage()%>

            </p>
    </body>
</html>
